package com.jiawa.train.business.controller.admin;

import com.jiawa.train.business.service.Impl.UserService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    private final UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }

    @PostMapping("/register")
    public String register(@RequestParam String userId) {
        userService.registerUser(userId);
        return "User " + userId + " registered!";
    }

    @GetMapping("/check")
    public String checkUser(@RequestParam String userId) {
        boolean exists = userService.isUserPossiblyRegistered(userId);
        return exists ? "User might be registered." : "User is not registered.";
    }
}
